package com.example.commom.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @author: bebm
 * @date: 2022/3/30 20:40
 * @description:
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PageRows<T> {

    private List<T> list;

    private long total;

    private int pageNum;

    private int pageSize;

    public long getPages(){
        if(this.total>0L &&this.pageSize >0 ){
            int pages=(int)(this.total / (long)this.pageSize);
            if(this.total%(long)this.pageSize>0L)
                ++pages;
            return (long)pages;
        }
        return 0L;
    }
}
